import requests
import bs4
import webbrowser

res = requests.get('http://www.qq.com')
res.raise_for_status()
# print(res.text)
soup = bs4.BeautifulSoup(res.text, 'html.parser')
linkElems = soup.select('a')
# print(len(linkElems))
# for linkElem in linkElems:
#     print(linkElem)
for i in range(5):
    print(linkElems[i].get('href'))
    webbrowser.open(linkElems[i].get('href'))